﻿using System;
using System.Collections.Generic;
using System.Text;

using MT.eVotePRS.Model;
using MT.eVotePRS.Service;
using MT.eVotePRS.Presentation.Core;

namespace MT.eVotePRS.Presentation.Logic
{
    public class InventoryTxnAction : AbstractForm
    {
        InventoryTxn _txn = null;

        private static readonly InventoryTxnService _txnService = InventoryTxnService.GetInstance();

        public InventoryTxnAction () : base()
        {
            _txn = new InventoryTxn();
        }

        public InventoryTxn Txn
        {
            get { return _txn; }
            set { _txn = value; }
        }

        public object CreateNewTxn( InventoryTxn txn)
        {
            if (_txn != null)
            {
                return _txnService.InsertInventoryTxn(txn);
            }
            return null;
        }

        public InventoryTxn CheckStudentStatus(string studentId)
        {
            _txn = _txnService.QueryLastTxnOfHandset(studentId);
            return _txn;
        }

        public InventoryTxn CheckHandsetStatus(string handsetId)
        {
            _txn = _txnService.QueryLastTxnOfHandset(handsetId);
            return _txn;
        }

    }
}
